﻿using NFine.Domain.Entity.BusinessManage;
using NFine.Domain.IRepository.BusinessManage;
using NFine.Repository.BusinessManage;
using NFine.Code;
using System.Collections.Generic;
using System.Linq;

namespace NFine.Application.BusinessManage
{
    public class D_GroupApp
    {
        private ID_GroupRepository service = new D_GroupRepository();

        //public List<D_GroupEntity> GetList(Pagination pagination, string keyword)
        //{
        //    var expression = ExtLinq.True<D_GroupEntity>();
        //    if (!string.IsNullOrEmpty(keyword))
        //    {
        //        expression = expression.And(t => t.F_Name.Contains(keyword));
        //        expression = expression.Or(t => t.F_Summary.Contains(keyword));
        //        expression = expression.Or(t => t.F_Spec.Contains(keyword));
        //    }
        //    return service.FindList(expression, pagination);
        //}

        public List<D_GroupEntity> GetList()
        {
            return service.IQueryable().ToList();
        }
        public D_GroupEntity GetForm(string keyValue)
        {
            return service.FindEntity(keyValue);
        }
        public void DeleteForm(string keyValue)
        {
            service.Delete(t => t.ID == keyValue);
        }
        public void SubmitForm(D_GroupEntity goodEntity, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                goodEntity.Modify(keyValue);
                service.Update(goodEntity);
            }
            else
            {
                goodEntity.Create();
                service.Insert(goodEntity);
            }
        }
    }
}
